﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Profile;
using System.Web.Security;

namespace timetableasy.Models
{
    public class ProfileCommon : ProfileBase
    {
        public virtual string FirstName
        {
            get
            {
                if (this.GetPropertyValue("FirstName") != null && !string.IsNullOrEmpty(this.GetPropertyValue("FirstName").ToString()))
                {
                    return (string)(this.GetPropertyValue("FirstName"));
                }
                return string.Empty;
            }
            set
            {
                this.SetPropertyValue("FirstName", value);
            }
        }

        public virtual string LastName
        {
            get
            {
                if (this.GetPropertyValue("LastName") != null && !string.IsNullOrEmpty(this.GetPropertyValue("LastName").ToString()))
                {
                    return (string)(this.GetPropertyValue("LastName"));
                }
                else
                    return string.Empty;
            }
            set
            {
                this.SetPropertyValue("LastName", value);
            }
        }

        public static ProfileCommon GetUserProfileByLogin(string login)
        {
            return Create(login) as ProfileCommon;
        }

        public static ProfileCommon GetUserProfile()
        {
            return Create(Membership.GetUser().UserName) as ProfileCommon;
        }
    }
}